package com.it.word_count;

import com.it.word_count.util.StreamUtils;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 基于有界流处理实现的word count.
 *
 * @author code1997
 */
public class StreamBoundWordCount {

    public static void main(String[] args) throws Exception {
        //1.创建执行环境
        StreamExecutionEnvironment executionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();
        //2.读取数据源文件
        String filePath = "data/word_count/batch/words.txt";
        DataStreamSource<String> dataStreamSource = executionEnvironment.readTextFile(filePath);
        //3.数据处理
        StreamUtils.printWordCount(dataStreamSource);
        //5.启动执行
        executionEnvironment.execute();


    }
}
